$(function() {
	initPage();
});
// ==================归档====================
$("#archiveBtn").click(function() {

	var data = {
		"content" : $("#contents").val(),
		"memo" : $("#memos").val()
	};
	var reportId = $("#reportId").val();
    $("#right").mLoading("show");
	$.ajax({
		url : rootPath + "/ui/archiveReport/archiveFinishedReport/" + reportId,
		dataType : 'json',
		type : 'post',
		data : data,
		success : function(result) {
			message("归档成功！")
			 $("#right").mLoading("hide");
			if (result.code == 1) {
				window.location.href = rootPath + "/ui/archiveReport";
			}
		}
	});
});
// =================页面初始化====================

var serverData = {};
var serverTable;

function initPage() {
var reportId = $("#reportId").val();

serverTable = $('#dataTable').DataTable({
		"serverSide" : true,
		"ordering" : false,
		"ajax" : {
			"dataType" : "json",
			"type" : "post",
			"cache" : false,
			"url" : window.rootPath
					+ '/ui/archiveReport/initRegisters/'
					+ reportId,
			"data" : function(d) {
				return $.extend({}, d, serverData);
			}
		},
		columns : [ {
			data : null,
			defaultContent : ""
		}, {
			data : 'registerEventName'
		}, {
			data : 'registerEventContent'
		}, {
			data : 'registerEventIdentify'
		} ,{
			data:'registerEventState.title'
		}],
		"drawCallback" : function(oSettings) {
			var k = 0;
			var total = oSettings.aiDisplay.length+ oSettings._iDisplayStart;
			for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
				$('td:eq(0)',oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
				k++;
			}

		}
	});
};